#pragma once

#include <iostream>
#include "structs.h"

using namespace std;

template <class T>
class ListTwoTwo
{
        Node<T> *head;
        Node<T> *tail;

    public:
        ListTwo(T);
        ListTwo();
        ~ListTwo(){}

        void addFromRfont(T);
        void addFromTail(T);
        void showFromFront(); // Показать от начала.

};

template <class T>
ListTwo<T>::ListTwo() // Пустой список.
{
    head = tail = new Node<T>;
    tail->Next = 0;
    tail->Prev = 0;
}

template <class T>
ListTwo<T>::ListTwo(T dta)
{

    head = tail = new Node<T>(dta);
    tail->Next = 0;
    tail->Prev = 0;
    ListTwo::addFromRfont(dta);
}


template <class T>
void ListTwo<T>::addFromRfont(T dta)
{
    Node<T>*pNode = new Node<T>(dta);
    pNode->Next = head;
    pNode->Prev = 0;
    head->Prev = pNode;
    head = pNode;
}
template <class T>
void ListTwo<T>::addFromTail(T dta)
{
    Node<T>*pNode = new Node<T>(dta);
    pNode->Next = tail;
    pNode->Prev = tail->Prev;
    tail->Prev->Next = pNode;
    tail->Prev = pNode;
}
template <class T>
void ListTwo<T>::showFromFront()
{
    Node<T>*pn;
    pn = head;
    while(pn!=tail)
    {
        cout << pn->data << endl;
        pn = pn->Next;
    }
}
